package com.stool.gram.web;

import com.stool.gram.domain.GramRequest;
import com.stool.gram.domain.GramResponse;
import com.stool.gram.domain.GramResult;
import com.stool.gram.service.DLService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/result")
public class GramController {

    @Autowired
    DLService dlService;

    @Value("${dlmodels.dir}")
    String dir;

    @PostMapping(value = "/")
    public GramResponse computeResults(@RequestBody GramRequest gramRequest) {
        List<GramResult> gramResults = dlService.computeResults(gramRequest.getData(), gramRequest.getComputeType());
        GramResponse gramResponse = GramResponse.create(gramResults);
        return gramResponse;
    }

    @GetMapping("/")
    public String getDir(){
        return dir;
    }
}
